import {
	WeaTools
} from 'ecCom'

export const getForm = (cPage, params = {}, currentStepIndex, whichFormWillBeUsed, formType) => {
	if (currentStepIndex === 0) {
		switch (cPage) {
			case 'loan':
				if (whichFormWillBeUsed === 'two') {
					return WeaTools.callApi('/api/hrm/pit/mortgage/getCertificateForm', 'GET', params);
				}
			case 'personalInfo':
			case 'childEducation':
			case 'continualEducation':
			case 'rent':
			case 'supportOlder':
				return WeaTools.callApi('/api/hrm/pit/personalInfo/getForm', 'GET', params);
			case 'familyMember':
				return WeaTools.callApi('/api/hrm/pit/familyInfo/getForm', 'GET', params);
			case 'recordInfo':
				if (whichFormWillBeUsed === 'one') {
					return WeaTools.callApi('/api/hrm/pit/recordSearch/getCondition', 'GET', params);
				}
				if (whichFormWillBeUsed === 'two') {
					return WeaTools.callApi('/api/hrm/pit/personalInfo/getForm', 'GET', params);
				}
				if (whichFormWillBeUsed === 'three') {
					return WeaTools.callApi('/api/hrm/pit/recordSearch/getDetail', 'GET', params);
				}
				if (whichFormWillBeUsed === 'four') {
					if (formType === 'personalInfo') {
						return WeaTools.callApi('/api/hrm/pit/personalInfo/getForm', 'GET', params);
					} else {
						return WeaTools.callApi('/api/hrm/pit/familyInfo/getForm?rela=spouse', 'GET', params);
					}
				}
		}
	} else if (currentStepIndex === 1) {
		switch (cPage) {
			case 'childEducation':
				if (whichFormWillBeUsed === 'one') {
					return WeaTools.callApi('/api/hrm/pit/childrenEdu/getCondition', 'GET', params);
				}
				if (whichFormWillBeUsed === 'two') {
					return WeaTools.callApi('/api/hrm/pit/childrenEdu/getForm', 'GET', params);
				}
				if (whichFormWillBeUsed === 'three') {
					return WeaTools.callApi('/api/hrm/pit/familyInfo/getForm', 'GET', params);
				}
			case 'continualEducation':
				if (whichFormWillBeUsed === 'one') {
					return WeaTools.callApi('/api/hrm/pit/edu/getCondition', 'GET', params);
				}
				if (whichFormWillBeUsed === 'two') {
					return WeaTools.callApi('/api/hrm/pit/edu/getForm', 'GET', params);
				}
			case 'loan':
				if (whichFormWillBeUsed === 'one') {
					return WeaTools.callApi('/api/hrm/pit/mortgage/getCondition', 'GET', params);
				}
				if (whichFormWillBeUsed === 'two') {
					return WeaTools.callApi('/api/hrm/pit/mortgage/getMortgageForm', 'GET', params);
				}
			case 'rent':
				if (whichFormWillBeUsed === 'one') {
					return WeaTools.callApi('/api/hrm/pit/rent/getCondition', 'GET', params);
				}
				if (whichFormWillBeUsed === 'two') {
					return WeaTools.callApi('/api/hrm/pit/rent/getForm', 'GET', params);
				}
			case 'supportOlder':
				if (whichFormWillBeUsed === 'one') {
					return WeaTools.callApi('/api/hrm/pit/support/getCondition', 'GET', params);
				}
				if (whichFormWillBeUsed === 'two') {
					return WeaTools.callApi('/api/hrm/pit/familyInfo/getForm', 'GET', params);
				}
		}
	} else {
		switch (cPage) {
			case 'childEducation':
				if (whichFormWillBeUsed === 'one') {
					return WeaTools.callApi('/api/hrm/pit/childrenEdu/getCostForm', 'GET', params);
				} else {
					return WeaTools.callApi('/api/hrm/pit/familyInfo/getForm', 'GET', params);
				}
			case 'loan':
				if (whichFormWillBeUsed === 'one') {
					return WeaTools.callApi('/api/hrm/pit/mortgage/getCostForm', 'GET', params);
				} else {
					return WeaTools.callApi('/api/hrm/pit/familyInfo/getForm', 'GET', params);
				}
			case 'rent':
				if (whichFormWillBeUsed === 'one') {
					return WeaTools.callApi('/api/hrm/pit/rent/getCostForm', 'GET', params);
				} else {
					return WeaTools.callApi('/api/hrm/pit/familyInfo/getForm', 'GET', params);
				}
			case 'supportOlder':
				return WeaTools.callApi('/api/hrm/pit/support/getCostForm', 'GET', params);
		}
	}
}

export const save = (cPage, params = {}, currentIndex, subDialogVisible, mainDialogVisible, formType) => {
	if (currentIndex === 0) {
		switch (cPage) {
			case 'personalInfo':
			case 'childEducation':
			case 'continualEducation':
			case 'rent':
			case 'supportOlder':
				return WeaTools.callApi('/api/hrm/pit/personalInfo/saveForm', 'POST', params);
			case 'familyMember':
				return WeaTools.callApi('/api/hrm/pit/familyInfo/saveForm', 'POST', params);
			case 'recordInfo':
				if (subDialogVisible) {
					if (formType === 'personalInfo') {
						return WeaTools.callApi('/api/hrm/pit/personalInfo/saveForm', 'POST', params);
					} else {
						return WeaTools.callApi('/api/hrm/pit/familyInfo/saveForm', 'POST', params);
					}
				} else {
					return WeaTools.callApi('/api/hrm/pit/recordSearch/save', 'POST', params);
				}
			case 'loan':
				if (!mainDialogVisible) {
					return WeaTools.callApi('/api/hrm/pit/mortgage/saveCertificateForm', 'POST', params);
				} else {
					return WeaTools.callApi('/api/hrm/pit/personalInfo/saveForm', 'POST', params);
				}
		}
	} else if (currentIndex === 1) {
		switch (cPage) {
			case 'childEducation':
				if (subDialogVisible) {
					return WeaTools.callApi('/api/hrm/pit/familyInfo/saveForm', 'POST', params);
				} else {
					return WeaTools.callApi('/api/hrm/pit/childrenEdu/saveForm', 'POST', params);
				}
			case 'continualEducation':
				return WeaTools.callApi('/api/hrm/pit/edu/saveForm', 'POST', params);
			case 'loan':
				return WeaTools.callApi('/api/hrm/pit/mortgage/saveMortgageForm', 'POST', params);
			case 'rent':
				return WeaTools.callApi('/api/hrm/pit/rent/saveForm', 'POST', params);
			case 'supportOlder':
				return WeaTools.callApi('/api/hrm/pit/support/saveForm', 'POST', params);
		}
	} else {
		switch (cPage) {
			case 'childEducation':
				if (!mainDialogVisible) {
					return WeaTools.callApi('/api/hrm/pit/childrenEdu/saveCostForm', 'POST', params);
				} else {
					return WeaTools.callApi('/api/hrm/pit/familyInfo/saveForm', 'POST', params);
				}
			case 'loan':
				if (!mainDialogVisible) {
					return WeaTools.callApi('/api/hrm/pit/mortgage/saveCostForm', 'POST', params);
				} else {
					return WeaTools.callApi('/api/hrm/pit/familyInfo/saveForm', 'POST', params);
				}
			case 'rent':
				if (!mainDialogVisible) {
					return WeaTools.callApi('/api/hrm/pit/rent/saveCostForm', 'POST', params);
				} else {
					return WeaTools.callApi('/api/hrm/pit/familyInfo/saveForm', 'POST', params);
				}
			case 'supportOlder':
				return WeaTools.callApi('/api/hrm/pit/support/saveCostForm', 'POST', params);
		}
	}
}

export const getRightMenu = (cPage, params = {}) => {
	switch (cPage) {
		case 'personalInfo':
			return WeaTools.callApi('/api/hrm/pit/personalInfo/getRightMenu', 'GET', params);
		case 'familyMember':
			return WeaTools.callApi('/api/hrm/pit/familyInfo/getRightMenu', 'GET', params);
		case 'childEducation':
			return WeaTools.callApi('/api/hrm/pit/childrenEdu/getRightMenu', 'GET', params);
		case 'continualEducation':
			return WeaTools.callApi('/api/hrm/pit/edu/getRightMenu', 'GET', params);
		case 'loan':
			return WeaTools.callApi('/api/hrm/pit/mortgage/getRightMenu', 'GET', params);
		case 'rent':
			return WeaTools.callApi('/api/hrm/pit/rent/getRightMenu', 'GET', params);
		case 'supportOlder':
			return WeaTools.callApi('/api/hrm/pit/support/getRightMenu', 'GET', params);
	}

}

export const getRecords = (cPage, params = {}) => {
	switch (cPage) {
		case 'familyMember':
			return WeaTools.callApi('/api/hrm/pit/familyInfo/getRecords', 'GET', params);
		case 'childEducation':
			return WeaTools.callApi('/api/hrm/pit/childrenEdu/getRecords', 'GET', params);
		case 'supportOlder':
			return WeaTools.callApi('/api/hrm/pit/support/getRecords', 'GET', params);
		case 'recordInfo':
			return WeaTools.callApi('/api/hrm/pit/recordSearch/getRecords', 'GET', params);
		case 'queryDeductionMoney':
			return WeaTools.callApi('/api/hrm/pit/costSearch/getRecords', 'GET', params);
	}

}

export const del = (cPage, params = {}) => {
	switch (cPage) {
		case 'familyMember':
			return WeaTools.callApi('/api/hrm/pit/familyInfo/delete', 'POST', params);
		case 'childEducation':
			return WeaTools.callApi('/api/hrm/pit/childrenEdu/delete', 'POST', params);
		case 'supportOlder':
			return WeaTools.callApi('/api/hrm/pit/support/delete', 'POST', params);
	}

}

export const getPreInfo = (cPage, params = {}) => {
	switch (cPage) {
		case 'childEducation':
			return WeaTools.callApi('/api/hrm/pit/childrenEdu/getInfo', 'GET', params);
		case 'continualEducation':
			return WeaTools.callApi('/api/hrm/pit/edu/getInfo', 'GET', params);
		case 'loan':
			return WeaTools.callApi('/api/hrm/pit/mortgage/getInfo', 'GET', params);
		case 'rent':
			return WeaTools.callApi('/api/hrm/pit/rent/getInfo', 'GET', params);
		case 'supportOlder':
			return WeaTools.callApi('/api/hrm/pit/support/getInfo', 'GET', params);
	}

}

export const getStep = (cPage, params = {}) => {
	switch (cPage) {
		case 'childEducation':
			return WeaTools.callApi('/api/hrm/pit/childrenEdu/getStep', 'GET', params);
		case 'continualEducation':
			return WeaTools.callApi('/api/hrm/pit/edu/getStep', 'GET', params);
		case 'loan':
			return WeaTools.callApi('/api/hrm/pit/mortgage/getStep', 'GET', params);
		case 'rent':
			return WeaTools.callApi('/api/hrm/pit/rent/getStep', 'GET', params);
		case 'supportOlder':
			return WeaTools.callApi('/api/hrm/pit/support/getStep', 'GET', params);
	}
}

export const getTableEditInfo = (params = {}) => {
	return WeaTools.callApi('/api/hrm/pit/support/getSupporterRecords', 'GET', params);
}

export const abandon = (params = {}) => {
	return WeaTools.callApi('/api/hrm/pit/recordSearch/abandon', 'POST', params);
}

export const saveRecords = (params = {}) => {
	return WeaTools.callApi('/api/hrm/pit/support/saveRecords', 'POST', params);
}

export const getFamilyInfo = (params = {}) => {
	return WeaTools.callApi('/api/hrm/pit/familyInfo/getFamilyInfo', 'GET', params);
}

export const checkInfo = (params = {}) => {
	return WeaTools.callApi('/api/hrm/pit/personalInfo/checkInfo', 'POST', params);
}